

package com.hazelcast.client.impl.protocol.task.map;

import com.hazelcast.client.impl.protocol.ClientMessage;
import com.hazelcast.client.impl.protocol.task.AbstractPartitionMessageTask;
import com.hazelcast.instance.impl.Node;
import com.hazelcast.internal.nio.Connection;
import com.hazelcast.map.impl.MapService;
import com.hazelcast.map.impl.MapServiceContext;
import com.hazelcast.map.impl.operation.MapOperationProvider;

abstract class AbstractMapPartitionMessageTask<P> extends AbstractPartitionMessageTask<P> {

    AbstractMapPartitionMessageTask(ClientMessage clientMessage, Node node, Connection connection) {
        super(clientMessage, node, connection);
    }

    protected final MapOperationProvider getMapOperationProvider(String mapName) {
        MapServiceContext mapServiceContext = getMapServiceContext();
        return mapServiceContext.getMapOperationProvider(mapName);
    }

    protected MapServiceContext getMapServiceContext() {
        MapService mapService = getService(MapService.SERVICE_NAME);
        return mapService.getMapServiceContext();
    }

    @Override
    protected final String getUserCodeNamespace() {
        return MapService.lookupNamespace(nodeEngine, getDistributedObjectName());
    }
}
